<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<% String basePath = request.getContextPath(); %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>

<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title></title>	
		<link rel="stylesheet" href="<%=basePath%>/resources/assets/css/core.css" />
		<link rel="stylesheet" href="<%=basePath%>/resources/assets/css/menu.css" />
		<link rel="stylesheet" href="<%=basePath%>/resources/assets/css/amazeui.css" />
		<link rel="stylesheet" href="<%=basePath%>/resources/assets/css/component.css" />
		<link rel="stylesheet" href="<%=basePath%>/resources/assets/css/page/form.css" />
		
		<link href="<%=basePath%>/resources/css/mui/mui.min.css" rel="stylesheet" />
		<style type="text/css">
		</style>
	</head>
	<body>
		<div class="account-pages">
			<div class="wrapper-page">
				<div class="text-center" style="padding-top:10%;">
	                <a  href="index.html" class="logo"><span>国台会务系统</span></a>
	            </div>
	            
	            <div class="m-t-40 card-box">
	            	<div class="text-center">
	                    <h4 class="text-uppercase font-bold m-b-0"></h4>
	                </div>
	                <div class="panel-body">
	                	<form class="am-form" id='login-form' action="${ctx}/userSystem/index"  method="post" onsubmit="return verification();" >
	                		<div class="am-g">
	                			<div class="am-form-group">
							      <input type="text" class="am-radius" id="userName" placeholder="用户名">
							    </div>
							
							    <div class="am-form-group form-horizontal m-t-20">
							      <input type="password" class="am-radius" id="password" placeholder="密码">
							    </div>
							    
							    <!-- <div class="am-form-group ">
		                           	<label style="font-weight: normal;color: #999;">
								        <input type="checkbox" class="remeber"> 记住密码
								    </label>
		                        </div> -->
		                        
		                        <div class="am-form-group ">
		                        	<button type="submit"  class="am-btn am-btn-primary am-radius">登录</button>
		                        	<!-- <button type="button" id="registerPage" class="am-btn am-btn-warning">注册</button> -->
		                        </div>
		                        
		                        <%-- <div class="am-form-group ">
		                        	<a href="${ctx}/user/retrievePasswordPage" class="text-muted"><i class="fa fa-lock m-r-5"></i> 忘记密码?</a>
		                        </div> --%>
	                		</div>

	                	</form>
							
	                </div>
	            </div>
			</div>
		</div>
		<script src="<%=basePath%>/resources/js/mui/mui.min.js"></script>
		<script  src="<%=basePath%>/resources/js/jquery-1.9.0/jquery.min.js"></script>
		
		<script>
		    var register = '${result}';
		    
		    if(register == '0'){
			    mui.alert("注册失败，请稍后重试！",'提示');
			   window.top.location.href = "${ctx}/user/registerPage";
		    }else if(register == '1'){
			   mui.alert("注册成功，请登录！",'提示');
		   }
		   debugger;
			function verification(){
				var result=false;
				if($('#userName').val().length<=0){
					mui.alert("用户名不能为空！",'提示');
				}else if($('#password').val().length<=0){
					mui.alert("密码不能为空！",'提示');
				}else{
					 mui.ajax('${ctx}/userSystem/login',{
						data:{"userName":$('#userName').val(),"password":$('#password').val()},
						dataType:'json',
						type:'post',
						async:false,
						success:function(data){
							if(data == 1){
								 mui.toast('登录成功'); 
								 result=true;
							 }else{
								 mui.alert("用户名或密码错误！",'提示');
							 }
						}
					}); 
				}
				return result;
			 }
			
			
			$("#registerPage").click(function(){
				window.top.location.href = "${ctx}/userSystem/registerPage";
				
			})
			
		</script>
	</body>
</html>
